package com.yuyang.wifi.utils.eventbus;


import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

/**
 * Created by zhuyuli on 2017/8/4.
 */

public class BaseEventManager {

    public BaseEventManager() {
    }

    @Subscribe
    public static void register(Object subscriber) { //注册
        if (!EventBus.getDefault().isRegistered(subscriber)) {
            EventBus.getDefault().register(subscriber);
        }
    }

    @Subscribe
    public static void unregister(Object subscriber) { //取消注册
        EventBus.getDefault().unregister(subscriber);
    }

    @Subscribe
    public static void post(int tagInt) {
        post(null, tagInt);
    }

    @Subscribe
    public static void post(String tagString) {
        post(null, tagString);
    }

    @Subscribe
    public static void post(Object event) {
        EventBus.getDefault().postSticky(new BaseEvent(event)); //发送通知
    }

    @Subscribe
    public static void post(Object data, int tagInt) {
        EventBus.getDefault().postSticky(new BaseEvent(tagInt, data));  //发送通知
    }

    @Subscribe
    public static void post(Object data, String tagString) {
        EventBus.getDefault().postSticky(new BaseEvent(tagString, data));  //发送通知
    }

    @Subscribe
    public static void post(Object data, int tagInt, String tagString) {
        EventBus.getDefault().postSticky(new BaseEvent(tagInt, tagString, data));  //发送通知
    }

    @Subscribe
    public static void post(Object data, int tagInt, int tagInt2, String tagString) {
        EventBus.getDefault().postSticky(new BaseEvent(tagInt, tagInt2, tagString, data));  //发送通知
    }
}
